package datamining;

import java.util.Comparator;
/**
 *
 * @author mhilke
 */
public class ItemSetComparator implements Comparator<ItemSet>
{

    /*
     * Gives an alphabetical ordering of the itemsets.
     */
    public int compare(ItemSet a, ItemSet b) {

        if (a.getElements().length != b.getElements().length)
        {
            System.out.println("Compare error! Different degree comparables!");
        }

        for (int i = 0; i < a.getElements().length; ++i)
        {
            if (a.getElements()[i].compareTo(b.getElements()[i]) < 0)
                return -1;
            else if (a.getElements()[i].compareTo(b.getElements()[i]) > 0)
                return 1;
        }
        return 0;
    }
}
